/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.xuexiang.xuidemo.slice;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.Text;
import ohos.app.Context;

import com.xuexiang.xuidemo.ResourceTable;
import com.xuexiang.xuidemo.view.SearchCompoent;

/**
 * 搜索框
 *
 * @since 2021-04-01
 */
public class SearchViewslice extends AbilitySlice {
    private DirectionalLayout mainlayout;
    private DependentLayout botomlayout;
    private DependentLayout deplayoutbut;
    private Context context;
    private SearchCompoent searchCompoent;
    private Text bottomtext;
    private Button button;

    /**
     * 加载页面
     *
     * @param intent
     */
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_assemblysearchslice);
        context = this;
        initview();
    }

    private void initview() {
        searchCompoent = (SearchCompoent) findComponentById(ResourceTable.Id_CompoentSearch);
        botomlayout = (DependentLayout) findComponentById(ResourceTable.Id_botom_layout);
      //  searchCompoent.botomlayout = botomlayout;
        mainlayout = (DirectionalLayout) findComponentById(ResourceTable.Id_mainlayout);
       // searchCompoent.backgroud = mainlayout; // 把整个布局给控件
        button = (Button) findComponentById(ResourceTable.Id_button);
        bottomtext = (Text) findComponentById(ResourceTable.Id_bottom_text);
       // searchCompoent.bottom_text = bottomtext;
        deplayoutbut = (DependentLayout) findComponentById(ResourceTable.Id_deplayoutbut);
        deplayoutbut.setVisibility(Component.HIDE);
        searchCompoent.setHideimg("SearchView");
        searchCompoent.setComponent(botomlayout,mainlayout,bottomtext);
    }
}
